home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
c_course.zip
/
PRINTDAT.C
< prev
next >
Wrap
Text File
|
1989-12-30
|
837b
|
27 lines
/* PRINTDAT.C printer as a pointer to a file */
/* In this example a single character is read from the file and printed.
This is in a one-at-a-time loop until it sees and EOF. */
#include "stdio.h"
main()
{
FILE *funny,*printer;
int c;
funny = fopen("TENLINES.TXT","r"); /* open input file */
printer = fopen("PRN","w"); /* open printer file */
do {
c = getc(funny); /* got one character from the file */
if (c != EOF) {
putchar(c); /* display it on the monitor */
putc(c,printer); /* print the character */
}
} while (c != EOF); /* repeat until EOF (end of file) */
fclose(funny);
fclose(printer);
}